package com.mzy.linear_struct;

import java.util.List;
import java.util.Random;
import java.util.StringJoiner;

/**
 * @Author: codermzy
 * @Date: 2024/04/19/11:20
 * @Description:
 */
public class TestAVLTree {

    public static void main(String[] args) {
        AVLTree tree = new AVLTree();


        // for (int i = 0; i < 100; i++) {
        //     // int num = (int) (Math.random() * 20 + 1);
        //     // tree.insert(num);
        //     tree.insert(i);
        // }
        // List<Integer> list = tree.levelOrderTraverse();
        // StringJoiner joiner = new StringJoiner(",", "[", "]");
        // list.forEach(a -> joiner.add(a.toString()));
        // System.out.println(joiner));
        // tree.reBalance();
        // tree.insert(11);
        tree.insert(7);
        tree.insert(15);
        tree.insert(5);
        tree.insert(9);
        tree.insert(13);
        tree.insert(20);
        tree.insert(3);
        tree.insert(8);
        tree.insert(10);
        tree.insert(12);
        tree.insert(14);
        tree.insert(18);
        tree.insert(25);
        tree.insert(19);
        List<Integer> list = tree.levelOrderTraverse();
        StringJoiner joiner = new StringJoiner(",", "[", "]");
        list.forEach(a -> joiner.add(a.toString()));
        System.out.println(joiner);

        tree.remove(15);

        list = tree.levelOrderTraverse();
        StringJoiner test = new StringJoiner(",", "[", "]");
        list.forEach(a -> test.add(a.toString()));
        System.out.println(test);
    }
}
